import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import manager from "../../../../test/json-serv";
import { IListResult, IFolder } from '@/types'
export function GET(request: NextRequest) {
    const searchParams = request.nextUrl.searchParams;

    const id = searchParams.get("id") || null;
    const file: IListResult<IFolder> = manager.queryFiles({ filters: { id } });
    const list: IListResult<IFolder> = manager.queryFiles({
        filters: { pid: id },
        page: 1,
        pageSize: 100000000,
    });
    const result = file?.rows[0] || {} as IFolder;
    result.children = list.rows
    return NextResponse.json<IFolder>(result);
}
